//
//  LeaveDetailFootView.m
//  OAProject
//
//  Created by yhj on 2017/2/22.
//  Copyright © 2017年 cdnunion. All rights reserved.
//

#import "LeaveDetailFootView.h"

@interface LeaveDetailFootView ()

// 通过
@property(nonatomic,strong)UIButton *passBtn;

// 拒绝
@property(nonatomic,strong)UIButton *rejectBtn;

@end

@implementation LeaveDetailFootView

-(instancetype)initWithFrame:(CGRect)frame
{
    self=[super initWithFrame:frame];
    if (self)
    {
        self.passBtn.hidden=NO;
        self.rejectBtn.hidden=NO;
    }
    return self;
}

// passBtn
-(UIButton *)passBtn
{
    if (!_passBtn) {
        _passBtn=[UIButton new];
        [self addSubview:_passBtn];
        [self.passBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(kmargin*3);
            make.top.mas_equalTo(kmargin);
            make.width.mas_equalTo((APPW-kmargin*8)/2);
//            make.height.mas_equalTo(kmargin*5);
            make.bottom.mas_equalTo(-kmargin);
        }];

        ViewBorderRadius(_passBtn,kmargin,1,ClearColor);
        [_passBtn setTitle:@"通过" forState:0];
        _passBtn.titleLabel.font=Font_Number(18);
        _passBtn.titleLabel.textColor=WhiteColor;
        [_passBtn addTarget:self action:@selector(passBtnEvent) forControlEvents:UIControlEventTouchUpInside];
        [_passBtn setBackgroundColor:[UIColor colorFromHexString:@"#59acd8"]];

    }
    return _passBtn;
}

// rejectBtn
-(UIButton *)rejectBtn
{
    if (!_rejectBtn) {
        _rejectBtn=[UIButton new];
        [self addSubview:_rejectBtn];
        [self.rejectBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(-kmargin*3);
            make.left.mas_equalTo(self.passBtn.mas_right).offset(kmargin*2);
            make.width.mas_equalTo((APPW-kmargin*8)/2);
            make.centerY.mas_equalTo(self);
            make.bottom.mas_equalTo(-kmargin);
        }];

        ViewBorderRadius(_rejectBtn,kmargin,1,ClearColor);
        [_rejectBtn setTitle:@"拒绝" forState:0];
        _rejectBtn.titleLabel.font=Font_Number(18);
        _rejectBtn.titleLabel.textColor=WhiteColor;
        [_rejectBtn addTarget:self action:@selector(rejectBtnEvent) forControlEvents:UIControlEventTouchUpInside];
        [_rejectBtn setBackgroundColor:[UIColor colorFromHexString:@"#59acd8"]];
        }
    return _rejectBtn;
}

-(void)passBtnEvent
{
    if (_delegate&&[_delegate respondsToSelector:@selector(passBtnEvent)])
    {
        [_delegate passBtnEvent];
    }
}


-(void)rejectBtnEvent
{
    if (_delegate&&[_delegate respondsToSelector:@selector(rejectBtnEvent)])
    {
        [_delegate rejectBtnEvent];
    }
}

@end
